package com.shenmazong.thread;

import java.util.ArrayList;
import java.util.Vector;

/**
 * @program: server-java-demo
 * @description: ArrayListNotSafeDemo
 * @author: 亮子说编程
 * @create: 2020-11-12 14:58
 **/
public class ArrayListNotSafeDemo {

    public static void main(String[] args) {
        Vector<String> strings = new Vector<>();

        for (int idx = 0; idx < 100; idx++) {
            new Thread(()->{
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                strings.add(Thread.currentThread().getName());
            }).start();
        }

        try {
            Thread.sleep(1000*5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(strings);
        System.out.println(strings.size());
    }
}
